package com.atguigu.springcloud.payment.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author lenovo
 * @version 1.0
 * @date 2020/11/11 11:07
 */
@Slf4j
@RestController
@RequestMapping("order")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class OrderController {

    @Value("${service-url.payment}")
    private String paymentService;

    final RestTemplate restTemplate;

    @GetMapping("/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id) {
        return restTemplate.getForObject(paymentService + "/payment/nacos/" + id , String.class);
    }

}
